package com.itheima.mapper;

import com.itheima.pojo.HotSetmeal;
import com.itheima.pojo.Protsetmealdo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.Date;
import java.util.List;

@Mapper
public interface ReportMapper {
    /**
     * 获取注册日期
     * @return
     */
    @Select("select regTime from czjk_name.t_member")
    List<LocalDate> listdate();

    /**
     * 根据日期统计人数
     * @param regTime
     * @return
     */
    @Select("select count(*) from czjk_name.t_member where regTime=#{regTime}")
    Integer sumdate(LocalDate regTime);

    /**
     * 获取套餐名字
     * @return
     */
    @Select("select b.name from czjk_name.t_order a,czjk_name.t_setmeal b where b.id=a.setmeal_id")
    List<String> listsetmeal();

    /**
     * 查询套餐有多少人预约了
     * @return
     */
    @Select("select b.name,count(*) value from czjk_name.t_order a,czjk_name.t_setmeal b where b.id=a.setmeal_id group by b.name")
    List<Protsetmealdo> sun();

    /**
     * 获取今日预约数
     * @param orderDate
     */
    @Select("select count(*) from czjk_name.t_order where orderDate like concat('%',#{orderDate},'%')")
    Integer datenow(LocalDate orderDate);

    /**
     * 获取本月的预约数
     * @param firstDayOfThisMonth
     * @param lastDayOfThisMonth
     * @return
     */
    @Select("select count(*) from czjk_name.t_order where orderDate >=#{firstDayOfThisMonth} and orderDate<= #{lastDayOfThisMonth}")
    Integer thisMonthOrderNumber(LocalDate firstDayOfThisMonth, LocalDate lastDayOfThisMonth);

    /**
     * 获取当前周的预约数
     * @param thisWeekMonday
     * @param thisWeekSunday
     * @return
     */
    @Select("select count(*) from czjk_name.t_order where orderDate >=#{thisWeekMonday} and orderDate<= #{thisWeekSunday}")
    Integer thisWeekNewMember(Date thisWeekMonday, Date thisWeekSunday);

    /**
     * 今日新增会员数
     * @param regTime
     * @return
     */
    @Select("select  count(*) from czjk_name.t_member where regTime like concat('%',#{regTime},'%')")
    Integer insertmumber(LocalDate regTime);

    /**
     * 统计总会员数
     * @return
     */
    @Select("select count(*) from czjk_name.t_member")
    Integer mumber();

    /**
     * 本月新增会员
     * @param firstDayOfThisMonth
     * @param lastDayOfThisMonth
     * @return
     */
    @Select("select count(*) from czjk_name.t_member where regTime >=#{firstDayOfThisMonth} and regTime<= #{lastDayOfThisMonth}")
    Integer mouthmumber(LocalDate firstDayOfThisMonth, LocalDate lastDayOfThisMonth);

    /**
     * 本周新增会员数
     * @param thisWeekMonday
     * @param thisWeekSunday
     * @return
     */
    @Select("select count(*) from czjk_name.t_member where regTime >=#{thisWeekMonday} and regTime<= #{thisWeekSunday}")
    Integer weekmumber(Date thisWeekMonday, Date thisWeekSunday);

    /**
     * 本日到诊数
     * @param now
     * @return
     */
    @Select("select count(*) from czjk_name.t_order where orderStatus='已到诊' and orderDate like concat('%',#{now},'%')")
    Integer todayVisitsNumber(LocalDate now);

    /**
     * 本月到诊数
     * @param firstDayOfThisMonth
     * @param lastDayOfThisMonth
     * @return
     */
    @Select("select count(*) from czjk_name.t_order where orderStatus='已到诊' and t_order.orderDate >=#{firstDayOfThisMonth} and orderDate<= #{lastDayOfThisMonth}")
    Integer thisMonthVisitsNumber(LocalDate firstDayOfThisMonth, LocalDate lastDayOfThisMonth);

    /**
     * 本周
     * @param thisWeekMonday
     * @param thisWeekSunday
     * @return
     */
    @Select("select count(*) from czjk_name.t_order where orderStatus='已到诊' and t_order.orderDate >=#{thisWeekMonday} and orderDate<= #{thisWeekSunday}")
    Integer thisWeekVisitsNumber(Date thisWeekMonday, Date thisWeekSunday);

    /**
     * 套餐预约数
     * @return
     */
    @Select("select b.name,count(*) setmealcount from czjk_name.t_order a,czjk_name.t_setmeal b where b.id=a.setmeal_id GROUP BY b.name")
    List<HotSetmeal>  hotSetmeal();

    /**
     * 查询总预约数
     * @return
     */
    @Select("select count(*) from czjk_name.t_order ")
    Integer ordersert();
}
